package com.mec.web.y2012.coreservlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.mec.beans.y2012.coreservlet.SalesBean;

@WebServlet("/ConditonalsServlet")
public class ConditonalsServlet extends HttpServlet {
	private static final long serialVersionUID = -8122054518959264318L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		SalesBean apples = new SalesBean(150.25, -75.25, 22.25, -33.57);
		SalesBean oranges = new SalesBean(-220.25, -49.57, 138.25, 12.25);
		
		req.setAttribute("apples", apples);
		req.setAttribute("oranges", oranges);
		//
		RequestDispatcher dispatcher = req.getRequestDispatcher("/el/conditionals.jsp");
		dispatcher.forward(req, resp);
	}


	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}


	private static final Logger logger = 
			Logger.getLogger(ConditonalsServlet.class);
}
